package com.kingmed.kmss.admin.modules.ums.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kingmed.kmss.admin.modules.ums.model.UmsBpmnGroup;
import com.kingmed.kmss.admin.modules.ums.service.UmsBpmnGroupService;
import com.kingmed.kmss.common.dto.admin.ums.BpmnGroupDTO;
import com.kingmed.kmss.common.dto.admin.ums.BpmnQueryDTO;
import com.kingmed.kmss.common.vo.CommonResponse;
import com.kingmed.kmss.common.vo.CommonResponseHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 后台流程角色表 前端控制器
 * </p>
 *
 * @author wyl
 * @since 2023-02-17
 */
@RestController
@RequestMapping("/ums/group")
@Api(tags = "ums流程角色表")
public class UmsBpmnGroupController {

    @Autowired
    private UmsBpmnGroupService bpmnGroupService;

    @ApiOperation("保存")
    @PostMapping(value = "/save")
    public CommonResponse<Integer> save(@Validated @RequestBody List<BpmnGroupDTO> reqDto) {
        return CommonResponseHelper.success(bpmnGroupService.update(reqDto));
    }

    @ApiOperation("根据ID获取详情")
    @GetMapping(value = "/detail")
    public CommonResponse<UmsBpmnGroup> queryById(@RequestParam Long id) {
        return CommonResponseHelper.success(bpmnGroupService.getBaseMapper().selectById(id));
    }

    @ApiOperation("根据ID批量删除")
    @PostMapping(value = "/delete")
    public CommonResponse<Integer> delete(@RequestBody List<Long> idList) {
        return CommonResponseHelper.success(bpmnGroupService.delete(idList));
    }

    @ApiOperation("列表查询")
    @PostMapping(value = "/queryList")
    public CommonResponse<List<BpmnGroupDTO>> queryList(@RequestBody BpmnQueryDTO queryQc) {
        return CommonResponseHelper.success(bpmnGroupService.queryList(queryQc));
    }

    @ApiOperation("分页查询")
    @PostMapping(value = "/page")
    public CommonResponse<Page<BpmnGroupDTO>> getPage(@RequestBody BpmnQueryDTO queryQc) {
        return CommonResponseHelper.success(bpmnGroupService.pageList(queryQc));
    }

}
